﻿using System.Linq;
using System.Collections.Generic;
using RSSReader.classesCustom;
using System;
using System.Web.UI.WebControls;

namespace RSSReader._testPages
{
    public partial class TestArt2 : System.Web.UI.Page
    {
        protected static RangeValidator psRangeValidator=new RangeValidator();

        [System.Web.Services.WebMethod]
        public static List<Article> GetAllArticlesWS()
        {
            return Global.dh2.onlineArticles;
        }

        [System.Web.Services.WebMethod]
        public static List<Article> GetPagedArticlesWS()
        {
            int pageNumber = 1, pageSize = 10;
            List<Article> pagedArticles = new List<Article>();
            for (int i = (pageNumber - 1) * pageSize; i < pageNumber * pageSize; i++)
            {
                pagedArticles.Add(Global.dh2.onlineArticles[i]);
            }
            return pagedArticles;
        }

        [System.Web.Services.WebMethod]
        public static List<Article> GetPageOfArticlesWS(int pageNumber, int pageSize)
        {
            //TODO: check parameters !!!
            List<Article> pagedArticles = new List<Article>();
            for (int i = (pageNumber - 1) * pageSize; i < pageNumber * pageSize; i++)
            {
                pagedArticles.Add(Global.dh2.onlineArticles[i]);
            }
            return pagedArticles;
        }

        [System.Web.Services.WebMethod]
        public static List<Article> GetPageofArticlesByCriteriaWS(ArticleCriteriaInString sfilter)
        {
            //TODO: check parameters !!!   
            ArticleFilter artFilter = new ArticleFilter(sfilter, Global.dh2.onlineArticles);
            ArticlePager artPager = new ArticlePager(sfilter, artFilter.getFilteredArticleList());

            return artPager.getArticlePage();            
        }

        
    }
}